//
//  MoneyManageViewController.m
//  项目三
//
//  Created by rimi on 15/9/28.
//  Copyright (c) 2015年 rimi. All rights reserved.
//

#import "MoneyManageViewController.h"

@interface MoneyManageViewController () {

    UIButton *_btn;
    UIView *_currentView;
}

- (void)initializeUserInterface; /**< 初始化用户界面 */

@end

@implementation MoneyManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeUserInterface];
}

- (void)initializeUserInterface {
    
    self.titleImageView.image = [UIImage imageNamed:@"理财服务-logo"];
    [super initializeUserInterface];
    
    NSString *currentVcName = CURRNTVIEW[0];
    Class currentClass = NSClassFromString(currentVcName);
    UIView *currentV = [[currentClass alloc] initWithFrame:DHFlexibleFrame(CGRectMake(0, 82, 708, 944))];
    _currentView = currentV;
    [self.view addSubview:currentV];
    
    for (int i = 0; i < 4; i ++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setBackgroundImage:[UIImage imageNamed:BIMAGE[i]] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:BSIMAGE[i]] forState:UIControlStateSelected];
        [btn addTarget:self action:@selector(respondsToSelectButton:) forControlEvents:UIControlEventTouchUpInside];
        [btn setFrame:DHFlexibleFrame(CGRectMake(211 + i * 115, 24, 102, 32))];
        [btn setTag:i + 100];
        
        if (i == 0) {
            _btn = btn;
            _btn.selected = YES;
        }
        [self.view addSubview:btn];
    }
}
- (void)respondsToSelectButton:(UIButton *)sender {
    
    if (sender == _btn) {
        return;
    }
    if (_currentView) {
        [_currentView removeFromSuperview];
    }
    NSString *selectName = CURRNTVIEW[sender.tag - 100];
    Class selectClass = NSClassFromString(selectName);
    UIView *selectView = [[selectClass alloc] initWithFrame:DHFlexibleFrame(CGRectMake(0, 82, 708, 944))];
    [self.view addSubview:selectView];
    _currentView = selectView;
    
    sender.selected = YES;
    _btn.selected = NO;
    _btn = sender;
}


@end
